package example

import (
	"context"

	"gitee.com/snitso/micro/app/evaluation/internal/conf"

	bizExample "gitee.com/snitso/micro/app/evaluation/internal/biz/example"
	"github.com/go-kratos/kratos/v2/log"
)

type exampleRepo struct {
	data   *conf.Data
	logger *log.Helper
}

func NewExampleRepo(data *conf.Data, logger log.Logger) bizExample.Repo {
	return &exampleRepo{
		data:   data,
		logger: log.NewHelper(logger),
	}
}

// GetExample 獲取地區
func (r *exampleRepo) GetExample(ctx context.Context, req *bizExample.Request) *bizExample.Reply {
	r.logger.Info("exampleRepo.GetExample")
	return &bizExample.Reply{
		Name: "hello " + req.Name,
	}
}

// SendTask 測試隊列
func (r *exampleRepo) SendTask(ctx context.Context, req *bizExample.Request) error {
	//taskInfo, err := r.data.Task.Enqueue(asynq.NewTask(constant.TypeExample, nil))
	//if err != nil {
	//	r.logger.Errorf("asynq enqueue error: %v", err)
	//}
	//r.logger.Infof("enqueued task: id=%s queue=%s", taskInfo.ID, taskInfo.Queue)

	return nil
}
